package demo01;

public class Originator {
    private String state;

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Originator() {
    }

    public Originator(String state) {
        this.state = state;
    }
//创建备忘录，保存信息
    public Memento CreateMenento(){
        return new Memento(state);

    }
    //恢复备忘录
    public void SetMemento(Memento memento){
        state=memento.getState();
    }
    public void Show(){
        System.out.println("State="+state);
    }
}
